const url = 'https://dongya.hualin688.com/applet.php?';
const Request = (options) => {
	let token = uni.getStorageSync('token') || ''
	let longitude = uni.getStorageSync('longitude') || ''
	let latitude = uni.getStorageSync('latitude') || ''
	let adcode = uni.getStorageSync('adcode') || '1'
	options.data.token = token
	options.data.lat = latitude
	options.data.lng = longitude
	options.data.adcode = adcode
	return new Promise((resolve, reject) => {
		uni.request({
			url:url,
			method: options.method || 'GET',
			data: options.data || {},
			success: (res) => {
				resolve(res);
				if(res.data.em == 'This account has been used or engaged'){
					uni.showToast({
						title:res.data.em,
						icon:'none'
					})
					uni.clearStorageSync();
					uni.setStorageSync('lang', 'en');
					uni.reLaunch({
						url:'/pages/login/login'
					})
				}
			},
			fail: (err) => {
				reject(err);
			},
		});
	})
}
export default Request

